package com.agile.leetcode.jsonpath.readjson2;

import cn.hutool.core.lang.TypeReference;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;

import java.io.File;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @author chenzhangkun
 * @ClassName ReadJson
 * @description: TODO
 * @date 2025年05月26日
 */
public class ReadJson {
    public static void main(String[] args) {
        String dev="D:\\czk\\dev.json";
        String origin="D:\\czk\\origin.json";
        JSON devJSON = JSONUtil.readJSON(new File(dev), Charset.defaultCharset());
        List<UserAuthorizedResourceDTO> devList = devJSON.toBean(new TypeReference<>() {});
        JSON originJSON = JSONUtil.readJSON(new File(origin), Charset.defaultCharset());
        List<UserAuthorizedResourceDTO> originList = originJSON.toBean(new TypeReference<>() {});

        Set<String> devSet = devList.stream().map(UserAuthorizedResourceDTO::getId).collect(Collectors.toSet());

        Set<String> orginSet = originList.stream().map(UserAuthorizedResourceDTO::getId).collect(Collectors.toSet());

        for (String s : devSet) {
            if (!orginSet.contains(s)){
                System.out.println(s);
            }
        }

    }
}
